<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<link rel="stylesheet" type="text/css"href="css/style.css"/>
		<script type="text/javascript" src=""></script>
		<title>水果管理系统</title>
	</head>
	<body>
		<h1>水果管理系统</h1>
		<table><!-- 水果表格 -->
		<?php
		require_once('./server/conn.php');
		$sql="select * from result";
		$result=$conn->query($sql);
		if($result->num_rows>0){
			while($row=$result->fetch_assoc()){
		?>		
		      <tr>
				  <td><?php echo $row['id']?></td>     <!-- <td> --><?php echo (4)['id'] ?><!-- </td> -->
				  <td><?php echo $row['name']?></td>
				  <td><?php echo $row['price']?></td>
				  <td><?php echo $row['gongxiao']?></td>
				  <td><?php echo $row['chandi']?></td>
				  <td>
					  <button onclick="toUpdate(this)">修改</button>
					  <button onclick="remove(this)">修改</button>
				  </td>
			  </tr>
			  <?php
			}
		}
		$conn->close(); 
		?>
		<tr>
			<td colspan="5">
				<a href="insert.php"><button>添加</button></a>
			</td>
		</tr>
		</table>
		<script type="text/javascript">
			function remove(ele){
				let id=ele.parentElement.parentElement.children[0].innerText;
				window.location.href="./server/remove_server.php?id="+id;
			}
			function toUpdate(ele){
				let id=ele.parentElement.parentElement.children[0].innerText;
				window.location.href="./update.php?id="+id;
			}
		</script>
	</body>
</html>
